import Router from 'koa-router'
// 格式转换
import IndexCon from '@/business/controller'
import {
  getListMid,
  getAllListMid,
  getAddMid,
  getAddBatchMid,
  getDetailMid,
  putMid,
  delMid,
  delBatchMid,
  exportMid
} from '@/business/middleware/equipment/jiaoyanguize.middleware'
import { addEditSchema, judgeIdSchema } from '@/business/schema'
import { exportExcelMid , formatHandle } from '@/business/middleware/common/common.middleware'
import JiaoyanguizeTable from '@/mysql/model/equipment/jiaoyanguize.model'
import { exportExcelSer } from '@/business/service'
import { addJudg, putJudg } from '@/business/schema/equipment/jiaoyanguize.schema'
import { hasPermi } from '@/business/middleware/common/auth'

const router = new Router({ prefix: '/equipment' })
// 查询列表
router.get('/jiaoyanguize/list', hasPermi('equipment:jiaoyanguize:query'), getListMid, formatHandle, IndexCon())
// 查询所有列表
router.post('/jiaoyanguize/all-list', hasPermi('equipment:jiaoyanguize:query'), getAllListMid, formatHandle, IndexCon())

// 新增
router.post(
  '/jiaoyanguize',
  hasPermi('equipment:jiaoyanguize:add'),
  addEditSchema(addJudg),
  getAddMid,
  IndexCon()
)
// 批量新增
router.post(
  '/jiaoyanguize/batch',
  hasPermi('equipment:jiaoyanguize:add'),
  // addEditSchema(addJudg),
  getAddBatchMid,
  IndexCon()
)

// 删除
router.delete('/jiaoyanguize/:id', hasPermi('equipment:jiaoyanguize:remove'), judgeIdSchema(), delMid, IndexCon())
// 按照设备名称删除对应的校验规则
router.post('/jiaoyanguize/device', hasPermi('equipment:jiaoyanguize:remove'), delBatchMid, IndexCon())

// 获取详细数据
router.get('/jiaoyanguize/detail/:id', hasPermi('equipment:jiaoyanguize:query'), judgeIdSchema(), getDetailMid, formatHandle, IndexCon())

// 修改
router.put(
  '/jiaoyanguize',
  hasPermi('equipment:jiaoyanguize:edit'),
  addEditSchema(putJudg),
  putMid,
  IndexCon()
)

// 导出列表(excel)
router.post(
  '/jiaoyanguize/export',
  hasPermi('equipment:jiaoyanguize:export'),
  exportExcelMid(exportExcelSer, JiaoyanguizeTable, {}),
  exportMid,
  IndexCon()
)
export default router